"use strict";

/**
 * 导出接口
 */
export{
    PI,
    module_name,
    sum,
    Point,
    GeoPoint
};

// 定义常量
const PI = 3.1415926;
let module_name = "geometry module";

//定义函数
function sum(a, b){
    return a + b;
}

//定义类
class Point{
    _x = 0;
    _y = 0;
    constructor(x=0.0, y=0.0){
        this._x = x;
        this._y = y; 
    }

    get X(){
        return this._x;
    }

    set X(x){
        this._x = x;
    }
    
    get Y(){
        return this._y;
    }

    set Y(y){
        this._y = y;
    }

    distance(pt){
        return Math.sqrt(Math.pow(this._x-pt.X, 2.0)+Math.pow(this._y-pt.Y, 2.0));
    }
}

//定义派生类
class GeoPoint extends Point{
    _srid = "";
    
    constructor(x, y, srid){
        super(x, y);
        this._srid = srid;
    }
}